package co.edu.javeriana.touresbalon.oms.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ada
 */
@Entity
@Table(name = "TRAVELER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Traveler.findAll", query = "SELECT t FROM Traveler t"),
    @NamedQuery(name = "Traveler.findByTravelerid", query = "SELECT t FROM Traveler t WHERE t.travelerid = :travelerid"),
    @NamedQuery(name = "Traveler.findByFname", query = "SELECT t FROM Traveler t WHERE t.fname = :fname"),
    @NamedQuery(name = "Traveler.findByLname", query = "SELECT t FROM Traveler t WHERE t.lname = :lname"),
    @NamedQuery(name = "Traveler.findByEmail", query = "SELECT t FROM Traveler t WHERE t.email = :email")})
public class Traveler implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "TRAVELERID")
    private String travelerid;
    @Size(max = 40)
    @Column(name = "FNAME")
    private String fname;
    @Size(max = 40)
    @Column(name = "LNAME")
    private String lname;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 40)
    @Column(name = "EMAIL")
    private String email;
    @ManyToMany(mappedBy = "travelerList", fetch = FetchType.LAZY)
    private List<Orders> ordersList;

    public Traveler() {
    }

    public Traveler(String travelerid) {
        this.travelerid = travelerid;
    }

    public String getTravelerid() {
        return travelerid;
    }

    public void setTravelerid(String travelerid) {
        this.travelerid = travelerid;
    }

    public String getFname() {
        return fname;
    }

    public void setFname(String fname) {
        this.fname = fname;
    }

    public String getLname() {
        return lname;
    }

    public void setLname(String lname) {
        this.lname = lname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @XmlTransient
    public List<Orders> getOrdersList() {
        return ordersList;
    }

    public void setOrdersList(List<Orders> ordersList) {
        this.ordersList = ordersList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (travelerid != null ? travelerid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Traveler)) {
            return false;
        }
        Traveler other = (Traveler) object;
        if ((this.travelerid == null && other.travelerid != null) || (this.travelerid != null && !this.travelerid.equals(other.travelerid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.edu.javeriana.touresbalon.oms.entities.Traveler[ travelerid=" + travelerid + " ]";
    }
    
}
